<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>邀请注册</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            -webkit-tap-highlight-color: transparent;
        }
        a{
            text-decoration: none;
        }
        body {
            background: url("/img/reg_bg.jpg") no-repeat;
            background-size:cover;
        }
        .header_img{
            margin: 1.2rem 10% 1.1rem;
            display: block;
            width: 80%;
        }
        .title{
            font-size: 0.3rem;
            color: #fff;
            background: -webkit-linear-gradient(left, #ffa080 , #ff62af);
            background: -o-linear-gradient(right, #ffa080 , #ff62af);
            background: -moz-linear-gradient(right, #ffa080 , #ff62af);
            background: linear-gradient(to right, #ffa080 , #ff62af);
            padding: 0.15rem 0.5rem;
            text-align: center;
            margin: 0 1.22rem;
            border-radius: 0.3rem;
        }
        .content{
            background: #5852be;
            margin: 0.27rem 0.4rem 0.25rem;
            padding: 0.3rem;
            border-radius: 0.2rem;
            position: relative;
        }
        .announcement{
            height: 0.3rem;
        }
        .announcement_right{
            float: left;
            font-size: 0.24rem;
            color: #fff;
            line-height: 0.3rem;
        }
        .announcement_img{
            display: block;
            height: 0.3rem;
            float: left;
        }
        .phone{
            margin: 0 0.1rem;
            color: #f1df7e;
        }
        input{
            display: block;
            padding: 0.25rem 0.65rem;
            border:none;
            outline: none;
            margin: 0.25rem 0;
            width: 100%;
            border-radius: 0.1rem;
            font-size: 0.3rem;
        }
        .clear{
            clear: both;
        }
        .yzm_box{
            display: flex;

        }
        .yzm_value{
            width: 55%;
            border-radius: 0.1rem 0 0 0.1rem;
        }
        .btn{
            border:none;
            outline: none;
            height: 0.92rem;
            margin: 0.25rem 0;
            text-align: center;
            width: 45%;
            border-radius: 0 0.1rem 0.1rem 0;
            background: #ffa664;
            color: #fff;
            font-size: 0.3rem;
            cursor: pointer;
        }
        .phone_value{
            margin-bottom: 0;
        }
        .password_value{
            margin-top:0;
        }
        .zhuce{
            border:none;
            outline: none;
            height: 0.92rem;
            background: #ffa664;
            color: #fff;
            margin: 0;
            display: block;
            width: 100%;
            border-radius: 0.1rem;
            font-size: 0.3rem;
            cursor: pointer;
        }
        .xieyi{
            font-size: 0.26rem;
            color: #fff;
            text-align: center;
            margin-top:0.25rem;
        }
        .xieyi a{
            font-size: 0.3rem;
            color: #fff;
        }
        footer{
            margin: 0.5rem 0.4rem 0;
        }
        .border{
            height: 0.02rem;
            background: #8982e9;
            color: #fff;
            font-size: 0.3rem;
            line-height: 0.08rem;
            text-align: center;
            margin-bottom: 0.35rem;
        }
        .border span {
            padding: 0 0.25rem;
            background: #645ddf;
        }
        .border_text{
            font-size: 0.26rem;
            color: #fff;
            line-height: 0.5rem;
        }
        .bottom_text{
            text-align: center;
            font-size: 0.26rem;
            color: #bec0fa;
            margin: 0.3rem 0;
        }
        .shadow{
            position: fixed;
            top:0;
            width: 100%;
            height: 100%;
            opacity: 0.2;
            background: #000;
            z-index: 2;
        }
        .toast{
            position: fixed;
            left:50%;
            top:50%;
            transform:translate3d(-50%,-50%,0);
            -webkit-transform:translate3d(-50%,-50%,0);
            background: #000;
            color: #fff;
            border-radius: 0.1rem;
            z-index: 3;
            font-size: 0.3rem;
            padding: 0.15rem 0.25rem;
        }
        .icon{
            position: absolute;
            width: 0.6rem;
            margin-top: 0.1rem;
        }

        .top-m{
            margin-top: 0.4rem;
        }
    </style>
</head>
<body>

<header>
        <a href="javascript:void(0);"><img src="/img/reg_hd.png" class='header_img'></a>
        <div class='title'>全国海量真实贷款用户任你选</div>
        <div class='content'>
            <img src="/img/reg_tl.png" class="icon top-m" />
            <input type="tel" maxlength='11' class='phone_value clear' placeholder='请输入手机号'>
            <div class='yzm_box'>
                <img src="/img/reg_cd.png" class="icon top-m" />
                <input type="tel" maxlength='6' class='yzm_value' placeholder='请输入验证码'>
                <button onclick="regCode()" type="button" class='btn'>获取验证码</button>
            </div>
            <img src="/img/reg_pw.png" class="icon" />
            <input type="password" minlength="6" class='password_value' placeholder='请输入至少六位数密码'>
            <button type="button" onclick="reg()" class='zhuce'>免费注册</button>
            <p class='xieyi'>注册即代表同意 <a href="javascript:void(0);">《用户协议》</a></p>
        </div>
</header>

<script src="/vendor/jquery/jquery.min.js"></script>

<script>
    $(function () {
        (function initFontSize (e, t) {
            var maxWidth = 960
            var defaultWidth = 750
            var defaultSize = 100
            var d = e.documentElement
            var resize = 'orientationchange' in window ? 'orientationchange' : 'resize'
            var computedFontSize = function () {
                var clientWidth = d.clientWidth
                clientWidth > maxWidth && (clientWidth = maxWidth)
                d.style.fontSize = defaultSize * (clientWidth / defaultWidth) + 'px'
            }
            computedFontSize()
            e.addEventListener && t.addEventListener(resize, computedFontSize, !1)
        })(document,window)
    })
    var str = window.location.href
    var pos = str.search("invite=")
    var invite = str.substr(pos).split("&")[0].split("=")[1]

    function reg() {
        var code = $(".yzm_value").val();
        var tel = $(".phone_value").val();
        var password = $(".password_value").val();
        if(tel.length != 11){
            error_show("手机号码长度异常")
            return
        }
        if(code.length != 4){
            error_show("验证码长度异常")
            return
        }
        if(password.length < 6){
            error_show("密码长度不足")
            return
        }


        $.ajax({
            url:'http://api.cyzgqd.com/open/get',
            headers:{
                "agent":"Web"
            },
            method:'get',
            crossDomain:true ,
            xhrFields: {
                withCredentials: true
            },
            data:{
                module:'UserService.register',
                invite:invite,
                tel:tel,
                code:code,
                password:password
            },
            success:function (data) {
                if(data.state == '000'){
                    error_show("注册成功，请下载APP查看免单券")
                }else{
                    error_show(data.msg)
                }
            },
            error:function (o, xml, ex) {
                error_show("网络错误")
            }
        })
    }

    function regCode() {
        var tel =  $(".phone_value").val()
        if(tel && tel.length == 11){
            $.ajax({
                url:'http://api.cyzgqd.com/open/get',
                headers:{
                    "agent":"Web"
                },
                method:'get',
                crossDomain:true ,
                xhrFields: {
                    withCredentials: true
                },
                data:{module:'CodeService.getToken',tel:tel} ,
                success:function (data) {
                    if(data.state == '000'){
                        var c_token = data.data
                        $.ajax({
                            url:'http://api.cyzgqd.com/open/get',
                            headers:{
                                "agent":"Web"
                            },
                            method:'get',
                            crossDomain:true ,
                            xhrFields: {
                                withCredentials: true
                            },
                            data:{
                                module:'CodeService.sendCodeByToken',
                                tel:tel,
                                c_token:c_token
                            },
                            success:function (data) {
                                if(data.state == '000'){
                                    wait_time(60)
                                }else{
                                    error_show(data.msg)
                                }
                            },
                            error:function (o, xml, ex) {
                                error_show("网络错误")
                            }
                        })
                    }else{
                        error_show(data.msg)
                    }
                },
                error:function (o, xml, ex) {
                    error_show("网络错误")
                }
            })
        }else {
            error_show("请输入正确的手机号码")
        }
    }

    function wait_time(Time) {
        $('.btn').attr('disabled',true).css({'background':"#ccc"})
        var time = setInterval(function(){
            --Time
            if (Time == 0) {
                clearInterval(time)
                $('.btn').html('重新获取验证码')
                $('.btn').attr('disabled',false).css({'background':"#ffa664"})
            } else {
                $('.btn').html(Time)
            }
        },1000)
    }
    function error_show(info) {
        $('body').append('<div class="shadow"></div>')
        $('body').append('<div class="toast">'+info+'</div>')
        setTimeout(function() {
            $('.shadow').remove()
            $('.toast').remove()
        },1800)
    }
</script>
</body>
</html>
